package reit.ass3;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.apache.log4j.Logger;


/**
 * The Class DammagedAssetsLinkedBlockingQueue.
 */
class DammagedAssetsLinkedBlockingQueue implements DammagedAssetsStorageInterface{

	/** The dammaged assets linked blocking queue. */
	private BlockingQueue<Asset> fDammagedAssetsLinkedBlockingQueue;

	/** The logger. */
	private Logger fLogger;

	/**
	 * Instantiates a new dammaged assets linked blocking queue.
	 */
	public DammagedAssetsLinkedBlockingQueue(){
		this.fLogger = Logger.getLogger(DammagedAssetsLinkedBlockingQueue.class);
		fDammagedAssetsLinkedBlockingQueue=new LinkedBlockingQueue<Asset>();
	}

	/* (non-Javadoc)
	 * @see ass3.DammagedAssetsStorageInterface#aquireDammagedAsset()
	 */
	@Override
	public Asset aquireDammagedAsset()
			throws InterruptedException {
		fLogger.info("Dammaged asset taken");
		return this.fDammagedAssetsLinkedBlockingQueue.take();
	}

	/* (non-Javadoc)
	 * @see ass3.DammagedAssetsStorageInterface#returnDammagedAsset(ass3.Asset)
	 */
	@Override
	public void returnDammagedAsset(final Asset asset) throws InterruptedException {
		fLogger.info("Dammaged asset inserted");
		this.fDammagedAssetsLinkedBlockingQueue.put(asset);
	}



	/* (non-Javadoc)
	 * @see ass3.DammagedAssetsStorageInterface#dammagedAssetsSize()
	 */
	@Override
	public Integer dammagedAssetsSize() {
		return new Integer(this.fDammagedAssetsLinkedBlockingQueue.size());
	}

}
